package com.example.demo2.controller;

import com.example.demo2.entity.Comment;
import com.example.demo2.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/{id}")
    public Comment findById(@PathVariable int id) {
        return commentService.findById(id);
    }

    @PutMapping("/{id}")
    public Comment update(@PathVariable int Id,@RequestBody Comment comment) {
        return commentService.update(comment);
    }

    @PostMapping
    public Comment insert(@RequestBody Comment comment) {
        return commentService.insert(comment);
    }

    @DeleteMapping
    public void delete(@PathVariable int id) {
        commentService.deleteById(id);
    }


}
